package com.sias.Loli.controller;

import com.sias.Loli.entity.Leader;
import com.sias.Loli.service.intf.LeaderService;
import com.sias.Loli.util.VerificationCode;
import com.sias.Loli.vo.PageBean;
import com.sias.Loli.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class LeaderController {
    @Autowired
    private LeaderService leaderService;
    /*
添加
     */
    @RequestMapping("/api/loli/leaderinsert.do")
    @ResponseBody
    public R leaderInsert(HttpSession session,Leader leader){
        System.out.println(leader);
        R r = leaderService.insertLeader(session,leader);
        return r;
    }
/*
登录
 */
    @RequestMapping("/api/loli/leaderinsertvf.do")
    @ResponseBody
    public R leaderselectvf(HttpSession session, Leader leader,String codes){
        System.out.println(leader);
        R r = leaderService.selectLeadervf(session,leader,codes);
        return r;
    }
    /*
    登录验证码！！！
     */
    @RequestMapping("/api/loli/VerificationCode.do")
    @ResponseBody
    public void VerificationCode(HttpSession session, HttpServletResponse response){
        VerificationCode.getVF(session,response);
    }
    /*
    各种查询
     */
    @RequestMapping("/api/loli/leaderselect.do")
    @ResponseBody
    public PageBean leaderselect(Leader leader){
        if (leader==null){
            leader=new Leader();
        }
        PageBean pageBean = leaderService.selectLeader(leader);
        return pageBean;
    }
}
